package com.example.qxfw.ybzz.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.qxfw.common.entity.qx.YbzzForecast;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
@DS("service")
public interface YbzzForecastMapper extends BaseMapper<YbzzForecast> {

    @Select("select distinct stationid from ybzz_forecast order by stationid")
    List<String> getStationId();

    @Select("select * from ybzz_forecast where forecastTime=${forecastTime} and forecastType=${forecastType} " +
        "order by cast(datechar as TIMESTAMP) + (ntimes || 'hour')::interval, stationid ")
    List<YbzzForecast> getListByType(String forecastTime,String forecastType);

    @Delete("delete from ybzz_forecast where " +
            " cast(datechar as timestamp)+ CAST((ntimes-forecastNTimes)|| hour as INTERVAL) =${shuZhiDate}  and ForecastType=${forecastType} and TimeChar = ${strTimeChar} and stationid in (${stationList})")
    Integer delete(String shuZhiDate,String forecastType,String strTimeChar,String stationList);


}
